package com.suixinsanren.design.command.demo04;

import org.junit.Test;

public class RemoteControlTestDrive {

    @Test
    public void test() {
        Fan fan = new Fan("小米", "客厅");
        Light light = new Light("米家", "卧室");

        LightOpenCommand lightOpenCommand = new LightOpenCommand(light);
        LightCloseCommand lightCloseCommand = new LightCloseCommand(light);

        FanOpenCommand fanOnCommand = new FanOpenCommand(fan);
        FanCloseCommand fanOffCommand = new FanCloseCommand(fan);

        RemoteControl remoteControl = new RemoteControl(3);

        remoteControl.setCommand(0, fanOnCommand, fanOffCommand);
        remoteControl.setCommand(1, lightOpenCommand, lightCloseCommand);

        remoteControl.onButtonWasPushed(0);
        remoteControl.offButtonWasPushed(0);

        remoteControl.undo();

        remoteControl.onButtonWasPushed(1);
        remoteControl.offButtonWasPushed(1);

        remoteControl.undo();
    }
}
